#include <iostream>
#include <vector>

using namespace std;
class Base{
public:
    virtual void fun()=0;
};
class Fac{
private:
    vector<Base *> vec;
public:
    void Add(Base * t){
        vec.push_back(t);
    }
    void Do(){
        vector<Base *>::iterator it;
        for(it = vec.begin();it != vec.end();it++ )
            (*it)->fun();
    }
};
class D1:public Base{
public:
    void fun(){
        cout<<"D1"<<endl;
    }
};
class D2:public Base{
public:
    void fun(){
        cout<<"D2"<<endl;
    }
};
int main() {
    D1 * d1 = new D1();
    D2 * d2 = new D2();
    Fac * fac = new Fac();
    fac->Add(d1);
    fac->Add(d2);
    fac->Do();
}